from __future__ import annotations

from datetime import date, datetime, timezone
from typing import Optional

from sqlmodel import SQLModel, Field


class Reminder(SQLModel, table=True):
    id: Optional[int] = Field(default=None, primary_key=True)
    title: str
    anniversary_date: date
    is_lunar: bool = False
    is_active: bool = True
    countdown_days: Optional[int] = Field(default=None)
    next_anniversary: Optional[str] = Field(default=None)
    years_passed: Optional[int] = Field(default=None)
    created_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))


class ReminderCreate(SQLModel):
    title: str
    anniversary_date: date
    is_lunar: bool = False
    is_active: bool = True


class ReminderRead(SQLModel):
    id: int
    title: str
    anniversary_date: date
    is_lunar: bool
    is_active: bool
    countdown_days: Optional[int]
    next_anniversary: Optional[str]
    years_passed: Optional[int]


class ReminderUpdate(SQLModel):
    title: Optional[str] = None
    anniversary_date: Optional[date] = None
    is_lunar: Optional[bool] = None
    is_active: Optional[bool] = None


